package com.mfp.java.testYou.ui.mvc;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mfp.java.testYou.core.AppContext;

/**
 * Contains all common MVC function
 */
abstract class AbstractMVC {

	// private static final Logger log = Logger.getLogger(AbstractMVC.class);

	private HttpServletRequest request;
	private HttpServletResponse response;

	private String msg, err;

	/**
	 * Will fire on every MVC load.
	 * 
	 * @param request
	 *            servletRequest from jsp page
	 * @param reponse
	 *            servletResponse from jsp page
	 */
	protected AbstractMVC(HttpServletRequest request, HttpServletResponse response) {
		this.request = request;
		this.response = response;
		msg = AppContext.getUserSession(getRequest()).popMessage();
		err = AppContext.getUserSession(getRequest()).popError();



	}

	protected HttpServletRequest getRequest() {
		return request;
	}

	protected HttpServletResponse getResponse() {
		return response;
	}

	public String getMessage() {
		return msg;
	}

	public boolean hasMessage() {
		return getMessage() != null;
	}

	public String getError() {
		return err;
	}

	public boolean hasError() {
		return getError() != null;
	}


}
